package com.lglin.common.config.security.point;

import com.lglin.common.utils.reponse.PrintOutUtil;
import com.lglin.common.utils.reponse.ResultBean;
import com.lglin.common.utils.reponse.ResultEnum;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Component
public class SelfAuthenticationEntryPoint implements AuthenticationEntryPoint {
    @Override
    public void commence(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AuthenticationException e) throws IOException {
        PrintOutUtil.printJsonOut(httpServletResponse, ResultBean.fail().setResultEnum(ResultEnum.Account_Not_Authentication));
    }
}
